* {
  padding: 0;
  margin: 0;
}
body,
.navbar,
ul {
  display: flex;
  justify-content: center;
  align-items: center;
}
body {
  height: 100vh;
  background: linear-gradient(200deg, #ddd6f3, #faaca8);
}
.navbar {
  position: relative;
  height: 50px;
  background-color: aliceblue;
  border-radius: 25px;
}
.navbar input {
  height: 50px;
  width: 50px;
  opacity: 0;
  cursor: pointer;
}
.navbar input:checked ~ ul {
  width: 280px;
}
.navbar input:checked ~ span:nth-of-type(1) {
  top: 50%;
  transform: rotate(-45deg);
  background-color: #fb7299;
  transition: transform 0.5s ease-out, top 0.5s ease-out;
}
.navbar input:checked ~ span:nth-of-type(2) {
  top: 50%;
  transform: rotate(45deg);
  background-color: #fb7299;
  transition: transform 0.5s ease-out, top 0.5s ease-out;
}
.navbar ul {
  width: 0;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.5s;
}
.navbar ul li {
  margin: 10px 5px;
}
.navbar ul li a {
  text-decoration: none;
}
.navbar ul li a:hover {
  color: #fb7299;
}
.navbar span {
  position: absolute;
  left: 8px;
  top: 40%;
  height: 4px;
  width: 35px;
  background-color: #6666;
  /* 现在span覆盖着复选框，鼠标放到span上是点不中复选框的，下面这个属性就可以解决这个问题，即便鼠标放到span上点击也能选中或取消选中复选框 */
  pointer-events: none;
  transition: transform 0.5s ease-in-out, top 0.5s ease-in-out 0.5s;
}
.navbar span:nth-of-type(2) {
  top: 60%;
}
